﻿@model CustomerForumSubscriptionsModel
@{    
    Layout = "_ColumnsTwo";

    //title
    NopHtml.AddTitleParts(T("PageTitle.ForumSubscriptions").Text);
    //page class
    NopHtml.AppendPageCssClassParts("html-account-page");
    NopHtml.AppendPageCssClassParts("html-forum-subscriptions-page");
}
@section left
{
    @await Component.InvokeAsync(typeof(CustomerNavigationViewComponent),new { selectedTabId = CustomerNavigationEnum.ForumSubscriptions })
}
<div class="page account-page forum-subscriptions-page">
    <div class="page-title">
        <h1>@T("Account.MyAccount") - @T("Account.ForumSubscriptions")</h1>
    </div>
    <div class="page-body">
        @await Component.InvokeAsync(typeof(WidgetViewComponent), new { widgetZone = PublicWidgetZones.CustomerForumSubscriptionsTop, additionalData = Model })
        @if (Model.ForumSubscriptions.Count > 0)
        {
            <div class="description">
                @T("Account.ForumSubscriptions.Description")
            </div>
            <script asp-location="Footer">
                $(function() {
                    $('#selectall').on('click', function () {
                        $('.subscription-list .rowcheckbox').prop('checked', $(this).is(':checked')).trigger('change');
                    });

                    $('.subscription-list .rowcheckbox').on('change', function (e) {
                        var numChkBoxes = $('.subscription-list .rowcheckbox').length;
                        var numChkBoxesChecked = $('.subscription-list .rowcheckbox:checked').length;
                        $('#selectall').prop('checked', numChkBoxes == numChkBoxesChecked && numChkBoxes > 0);
                    });
                });
            </script>
            <form asp-route="@NopRouteNames.Standard.CUSTOMER_FORUM_SUBSCRIPTIONS" method="post">
                <div class="subscription-list">
                    <div class="table-wrapper">
                        <table class="data-table">
                            <colgroup>
                                <col width="1" />
                                <col />
                            </colgroup>
                            <thead>
                            <tr>
                                <th class="select-boxes">
                                    <input type="checkbox" id="selectall" aria-labelledby="info-col-caption" />
                                </th>
                                <th class="info" id="info-col-caption">
                                    @T("Account.ForumSubscriptions.InfoColumn")
                                </th>
                            </tr>
                            </thead>
                            <tbody>
                            @for (var i = 0; i < Model.ForumSubscriptions.Count; i++)
                            {
                                var item = Model.ForumSubscriptions[i];
                                <tr @(i % 2 == 0 ? Html.Raw(" class=\"odd\"") : Html.Raw(" class=\"even\""))>
                                    <td class="select-boxes">
                                        <input type="checkbox" name="fs@(item.Id)" class="rowcheckbox" aria-labelledby="info-col-caption" />
                                    </td>
                                    <td class="info">
                                        @if (item.TopicSubscription)
                                        {
                                            @Html.RouteLink(item.Title, NopRouteNames.Standard.TOPIC_SLUG, new { Id = item.ForumTopicId, slug = item.Slug })
                                        }
                                        else
                                        {
                                            @Html.RouteLink(item.Title, NopRouteNames.Standard.FORUM_SLUG, new { Id = item.ForumId, slug = item.Slug })
                                        }
                                    </td>
                                </tr>
                            }
                            </tbody>
                        </table>
                    </div>
                    @{
                        var pager = await Html.PagerAsync(Model.PagerModel);
                    }
                    @if (!string.IsNullOrEmpty(await pager.RenderHtmlContentAsync()))
                    {
                        <div class="pager">
                            @pager
                        </div>
                    }
                    <div class="buttons">
                        <button type="submit" class="button-1 delete-selected-fs-button">@T("Account.ForumSubscriptions.DeleteSelected")</button>
                    </div>
                </div>
            </form>
        }
        else
        {
            <div class="no-data">
                @T("Account.ForumSubscriptions.NoSubscriptions")
            </div>
        }
        @await Component.InvokeAsync(typeof(WidgetViewComponent), new { widgetZone = PublicWidgetZones.CustomerForumSubscriptionsBottom, additionalData = Model })
    </div>
</div>
